/**
 * @description: delet tree node
 * @param origin 数据源
 * @param id
 * @return new tree data  纯函数
 */
export function deleteTreeNode<T extends TreeData>(origin: T[], id: string | number, key: keyof T = "id"): T[] {
  return origin.filter((node) => {
    if (node.children) {
      node.children = deleteTreeNode(node.children as T[], id, key);
    }
    return node[key] !== id;
  });
}
